<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="utf-8"/>
    <title>order</title>
    <link rel="stylesheet" type="text/css" href="css/public.css"/>
    <link rel="stylesheet" type="text/css" href="css/proList.css"/>
    <link rel="stylesheet" type="text/css" href="css/mygxin.css"/>
</head>
<body>
<div class="head ding">
    <div  th:replace="common :: head" ></div>

</div>
<div class="order cart mt">
    <div class="site"><p class="wrapper clearfix"><span class="fl">订单确认</span><img class="top"
                                                                                   src="img/temp/cartTop02.png"></p>
    </div><!-----------------orderCon------------------->
    <div class="orderCon wrapper clearfix">
        <div class="orderL fl"><!--------h3----------------><h3>收件信息<a href="javascript:void(0)" class="fr edit1">新增地址</a></h3>
            <!--------addres---------------->
            <div id="edit">
                <div class="addres clearfix">
                    <div class="addre fl on">
                        <div class="tit clearfix"><p class="fl" th:text="${session.portalUser.address.name}"><span class="default">[默认地址]</span></p>
                            <p class="fr"><a href="#" class="edit">编辑</a></p></div>
                        <div class="addCon"><p th:text="${session.portalUser.address.city+' '+session.portalUser.address.address}"></p>
                            <p th:text="${session.portalUser.address.phone}"></p></div>
                    </div>
                </div>
            </div>
            <h3>支付方式</h3><!--------way---------------->
            <div class="way clearfix"><img class="on" src="img/temp/way01.jpg"><img src="img/temp/way02.jpg"><img
                    src="img/temp/way03.jpg"><img src="img/temp/way04.jpg"></div>
            <h3>选择快递</h3><!--------dis---------------->
            <div class="dis clearfix"><span class="on">顺风快递</span><span>百世汇通</span><span>圆通快递</span><span>中通快递</span>
            </div>
        </div>
        <div class="orderR fr">
            <div class="msg"><h3>订单内容<a href="cart.html" class="fr">返回购物车</a></h3><!--------ul---------------->
                <ul th:each="cart:${cartList}"  th:if="${cart.isPayment==false}" class="clearfix">
                    <li class="fl"><img width="80" height="80" th:src="${cart.goods.image}"></li>
                    <li class="fl"><p th:src="${cart.goods.title}"></p>
                        <p th:text="${'颜色分类:'+cart.goods.goodsBoOne.type}"></p>
                        <p th:text="${'数量:'+cart.orderNumber}"></p></li>
                    <li th:text="${'￥'+cart.orderNumber*cart.goods.price}"  class="fr"></li>
                </ul>

            </div><!--------tips---------------->
            <div class="tips"><p><span class="fl">商品金额：</span><span class="fr" th:text="${'￥'+sum}"></span></p>
                <p><span class="fl">优惠金额：</span><span class="fr">￥0.00</span></p>
                <p><span class="fl">运费：</span><span class="fr">免运费</span></p></div><!--------tips count---------------->
            <div class="count tips"><p><span class="fl">合计：</span><span class="fr" th:text="${'￥'+sum}"></span></p></div>
            <!--<input type="button" name="" value="去支付">--> <a href="javascript:void(0)" onclick="paym(this.id)" th:id="${id}" class="pay">去支付</a></div>
    </div>
</div><!--编辑弹框--><!--遮罩-->
<div class="mask"></div>
<div  class="adddz editAddre" >
    <form id="updateForm" onsubmit="return false">

        <input name="id" th:value="${session.portalUser.address.id}"  style="display: none;" />
        <input type="text" name="name" class="on" placeholder="姓名" th:value="${session.portalUser.address.name}" required/>
        <input type="text" name="phone" placeholder="手机号" th:value="${session.portalUser.address.phone}" required/>
        <input type="text" name="city" th:value="${session.portalUser.address.city}" placeholder="省/市/县区,比如湖南省郴洲市桂阳县" required/>
        <textarea name="address" rows="" cols="" th:value="${session.portalUser.address.address}" th:text="${session.portalUser.address.address}" placeholder="详细地址" required></textarea>
        <div class="bc"><input type="submit" onclick="edit(true)" value="保存"/><input type="button" value="取消"/></div>
    </form>
</div>
<div  class="readd editAddre" >
    <form id="addForm" onsubmit="return false">
        <input type="text" name="name" class="on" placeholder="姓名" required/>
        <input type="text" name="phone" placeholder="手机号"  required/>
        <input type="text" name="city" placeholder="省/市/县区,比如湖南省郴洲市桂阳县" required/>
        <textarea name="address" rows="" cols="" placeholder="详细地址" required></textarea>
        <div class="bc"><input type="submit" onclick="edit(false)" value="保存"/><input type="button" value="取消"/></div>
    </form>
</div>

<div th:replace="common :: gotop"></div>

<div  th:replace="common :: footer"></div>
<script src="js/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/public.js" type="text/javascript" charset="utf-8"></script>
<script src="js/pro.js" type="text/javascript" charset="utf-8"></script>
<script src="js/user.js" type="text/javascript" charset="utf-8"></script>
<script>
    function paym(id) {
        $.post("cart/del",{id},function (result) {
            if (result=='ok'){
                window.location.replace("ok")
            }
        })
    }

    function edit(flag) {
        var url = ''
        var id = ''
        if (flag){
            url='/address/updateOrder'
            id ='updateForm'
        }else {
            url='/address/saveOrder'
            id ='addForm'
        }
        $.ajax({
            //几个参数需要注意一下
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            url: url ,//url
            data: $('#'+id).serialize(),
            success: function (result) {
               if (result>0){
                   alert("编辑成功")
                   $("#edit").load(location.href + " #edit")
               }
            },

        });
    }
</script>
</body>
</html>